﻿using System;

namespace RouteMaster
{
    public static class TimeSpanString
    {
        public static string Stringify(TimeSpan ts)
        {
            bool addEssMinutes = false;
            if (ts.Minutes != 1)
                addEssMinutes = true;
  
            string m = "" + ts.Minutes + " minute" + (addEssMinutes ? "s" : "");          

            if (ts.TotalHours < 1)
            {
                return m;
            }
     
            bool addEssHours = false;
            if (ts.Hours != 1)
                addEssHours = true;

            string h = "" + ts.Hours + " hour" + (addEssHours ? "s" : "");
            if (ts.TotalDays < 1)
            {
                return h + " " + m;
            }

            bool addEssDays = false;
            if (ts.Days != 1)
                addEssDays = true;
         
            string d = "" + ts.Days + " day" + (addEssDays ? "s" : "");
            return d + " " + h + " " + m;
        }
    }
}
